package com.zmh.service.time.job;

import org.quartz.DisallowConcurrentExecution;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.quartz.QuartzJobBean;

import com.zmh.common.DateUtil;
import com.zmh.dao.WorkPunchMapper;
import com.zmh.entity.MailEntity;
import com.zmh.service.msg.MailService;

/** 
 * 
 * @author: zhoumh
 * @version: 创建时间：2018年12月6日 下午2:19:56 
 * @Description: 
*/ 
@DisallowConcurrentExecution
public class WorkPunchAmTimer extends QuartzJobBean {
	private static Logger logger = LoggerFactory.getLogger(WorkLogWYTimer.class);
	@Autowired
	private WorkPunchMapper workPunchMapper;
	@Autowired
	private MailService mailService;
	@Override
    protected void executeInternal(JobExecutionContext jobExecutionContext) throws JobExecutionException {
    	logger.info("WorkPunchAmTimer任务开始");
        try {
        	int result = workPunchMapper.getCount(DateUtil.getDate(), "am");
        	if (result == 0) {
                mailService.saveMail(new MailEntity("考勤消息<zhoumh1985@qq.com>", "zmh1812@qq.com", DateUtil.getDate()+"上午考勤提醒", "还未收到考勤打卡信息，请确认是否打卡！","sendSimpleMail"));
			}
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
        logger.info("WorkPunchAmTimer任务结束");
    }
}
